package com.chen.proxiedServerForTest.httpserver;

import java.util.HashMap;
import java.util.Map;

public class BootStrap {
    public static void main(String[] args) {
        String serverId = "0";
        if (args != null && args.length > 0){
            serverId = args[0];
        }

        Map<String,Class> map = new HashMap<>();
        map.put("1",HttpServer1.class);
        map.put("2",HttpServer2.class);
        map.put("3",HttpServer3.class);

        if (serverId.equals("0")){
            for (Class clazz :map.values()){
                startServer(clazz);
            }
        }else {
            startServer(map.get(serverId));
        }


    }

    static void startServer(Class clazz){
        try {
            Thread th = (Thread) clazz.newInstance();
            th.start();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
